Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fast-usdc): detect transfer completion in cli #10717

Merged
merged 1 commit into from
Dec 18, 2024
Merged

Conversation

samsiegart
Copy link
Contributor

@samsiegart samsiegart commented Dec 17, 2024

fixes #10339

Description

This just simply polls the USDC balance on the destination account repeatedly to see when it changes

Security Considerations

There are ways to exploit this detection logic. Namely, if the user or someone else sends USDC to the EUD before the transfer finishes, the CLI would prematurely report that the transfer completed. We could refine this logic if needed, but it's just a UX issue and doesn't affect whether or not they get their funds.

Scaling Considerations

Polls the API url every 1.2 seconds temporarily, shouldn't be too much of an impact.

Documentation Considerations

Updated the demo config file with an example for osmosis chain.

Testing Considerations

We can't test this fully e2e until we have a real testnet setup with the FU contract and IBC to noble testnet and another cosmos chain. However, added unit tests to verify the new transfer detection functionality in this PR. The previously existing functionality of the transfer flow was partially tested in testnets when it was added in #10437 (see "Testing Considerations").

Upgrade Considerations

This CLI code does not run on-chain.

Copy link

cloudflare-workers-and-pages bot commented Dec 17, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2828444
Status: ✅  Deploy successful!
Preview URL: https://3c30b8b6.agoric-sdk.pages.dev
Branch Preview URL: https://srs-fu-transfer-cli.agoric-sdk.pages.dev

View logs

@samsiegart samsiegart requested a review from turadg December 17, 2024 19:11
@samsiegart samsiegart marked this pull request as ready for review December 17, 2024 19:11
@samsiegart samsiegart requested a review from a team as a code owner December 17, 2024 19:11
Copy link
Member

@turadg turadg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the agoric-sdk PR template with special attention to the Test Plan section. How do we know this will work with Noble ? The issue describes integrating with their x/forwarding accounts.

packages/fast-usdc/src/cli/cli.js Show resolved Hide resolved
address,
api,
denom,
fetch = globalThis.fetch,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is provided in every instance. please require it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,14 @@
/* global globalThis */

export const queryUSDCBalance = async (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please annotate the types

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting used to this style vs @param. More like .ts and will make automatic conversions to that syntax easier.

@@ -0,0 +1,14 @@
/* global globalThis */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general prefer /* eslint-env node */ to indicate the environment a module expects.

see #8702

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are they mutually exclusive? I want to use globalThis to namespace the global fetch, and have the arg default to that. I guess I'd have to rename it to fetchArg or something. But either way, I removed the default arg as you said, so it's moot.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are they mutually exclusive?

You mean is it okay to have both these lines?

/* global globalThis */
/* eslint-env node */

It doesn't cause harm but the first is accomplished by the second so it gives the reader pause as to why it's included.

@samsiegart
Copy link
Contributor Author

Please use the agoric-sdk PR template with special attention to the Test Plan section. How do we know this will work with Noble ? The issue describes integrating with their x/forwarding accounts.

Just updated the description. The x/forwarding stuff was implemented and tested in a previous PR (details there). This PR is just for detecting the transfer completion and reporting the time, which was the last part of the acceptance criteria for #10339.

@samsiegart samsiegart requested a review from turadg December 18, 2024 06:40
packages/fast-usdc/test/cli/transfer.test.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,14 @@
/* global globalThis */

export const queryUSDCBalance = async (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting used to this style vs @param. More like .ts and will make automatic conversions to that syntax easier.

@samsiegart samsiegart added the automerge:rebase Automatically rebase updates, then merge label Dec 18, 2024
@mergify mergify bot merged commit 6fbd20a into master Dec 18, 2024
81 checks passed
@mergify mergify bot deleted the srs-fu-transfer-cli branch December 18, 2024 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI for Fast USDC transfer
2 participants